import pymysql

class DB:
    def __init__(self):
        self.conn = pymysql.connect(host="localhost",port=3306,db="mylab",user="root",password="root",charset="utf8",cursorclass=pymysql.cursors.DictCursor)
        self.cursor = self.conn.cursor()
    def find(self,sql):
        self.cursor.execute(sql)
        return self.cursor.fetchone()
    def find_all(self,sql):
        self.cursor.execute(sql)
        return self.cursor.fetchall()
    def update(self,sql):
        self.cursor.execute(sql)
        self.conn.commit()
    def close(self):
        self.cursor.close()
        self.conn.close()
db1 = DB()